﻿#include "views/MainWindow/MainWindow.h"
#include "views/SplashScreen/SplashScreen.h"
#include "stores/DataStroes.h"
#include "components/SingleInstanceApplication/SingleInstanceApplication.h"


int main(int argc, char *argv[])
{
//     QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    QApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);

    SingleInstanceApplication app(argc, argv);
    if (!app.isPrimary()) {
        // 第二个实例立即退出
        return 0;
    }

    // 启动动画
    SplashScreen splash;
    splash.show();

    // 先加载数据再渲染界面！
    DataStroes::instance()->loadStores();

    MainWindow w;
    w.show();

    // 这会激活已存在的实例
    app.setMainWindow(&w);

    // 结束启动动画
    splash.finish(&w);

    return app.exec();
}
